
import { computed, ref } from "vue";

const zIndex = ref(0)  //在模块最外层，所以只在模块初次导入时执行一次
const useZIndex = (initialValue = 2000) =>{
  const initialZIndex = ref(initialValue)
  const currentZIndex = computed(()=>initialZIndex.value+zIndex.value)  //定义
  const nextZIndex = ()=>{
    zIndex.value++  //执行这一行之后，vue的响应式系统会自动触发计算属性，重新计算currentZIndex
    return currentZIndex.value
  }
  return{
    currentZIndex,
    nextZIndex,
    initialZIndex
  }
}
export default useZIndex